package com.qwz.example;

import com.qwz.common.TempDb;
import com.qwz.example.component.Component;

import java.util.Date;

/**
 * @author Qiuwuzhi
 * @version V1.0
 * @Description: 装饰器对象，计算当月团队业务奖金
 * @Package com.qwz.example.GroupPrizeDecorator
 * @date 2019/12/19 13:49
 */
public class GroupPrizeDecorator extends Decorator {
    /**
     * 通过构造方法传入被装饰的对象
     *
     * @param component
     */
    public GroupPrizeDecorator(Component component) {
        super(component);
    }

    @Override
    public double calcPrize(String user, Date begin, Date end) {

        //先获取前面运算出来的奖金
        double money = super.calcPrize(user, begin, end);
        //计算当月团队业务奖金，先计算出团队总的业务额，再乘以0.01
        //假设都是一个团队
        double group = 0.0;
        for (double d : TempDb.mapMonthSaleMoney.values()) {
            group += d;
        }
        double prize = group * 0.01;
        System.out.println(user + "-当月团队奖金-" + prize);
        return prize + money;
    }
}
